<template>
    <div class="app-container">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <el-form-item label="发现时间">
          <el-date-picker
                    clearable
                    v-model="queryParams.beginCreateTime  "
                    type="datetime"
                    placeholder="隐患发现时间"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    default-time="00:00:00"
                  >
                  </el-date-picker>
        </el-form-item>
        <el-form-item label="检查人">
          <el-input
            v-model="queryParams.inspectedUsers"
            placeholder="请输入检查人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="隐患等级">
          <el-select v-model="queryParams.level" placeholder="请选择隐患等级">
            <el-option label="一般隐患" :value="1"></el-option>
            <el-option label="重大隐患" :value="2"></el-option>
          </el-select>
        </el-form-item>
  
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <!-- v-hasPermi="['app:vehicles:add']" 新增权限 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            >新增</el-button
          >
        </el-col>
        <el-col :span="1.5">
        <el-button
        v-show="activeName == 'fourth'"
          size="mini"
          type="warning"
          icon="el-icon-download"
          @click="downloadPDF()"
          >导出</el-button
        >
        <el-popconfirm
          confirm-button-text="好的"
          cancel-button-text="不用了"
          icon="el-icon-info"
          icon-color="red"
          title="确定删除吗？"
          @confirm="handleDelete"
        >
          <el-button
            v-show="activeName == 'first'"
            type="danger"
            plain
            slot="reference"
            icon="el-icon-delete"
            size="mini"
            v-hasPermi="['system:device:remove']"
            >删除</el-button
          >
        </el-popconfirm>
      </el-col>
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>
  
      <el-tabs v-model="activeName">
        <el-tab-pane label="隐患发现" name="first">
          <el-table :data="ListVehicles" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" />
            <!-- <el-table-column label="标题" align="center" prop="title" /> -->
            <el-table-column label="发现问题" align="center" prop="desci">
            </el-table-column>
            <el-table-column label="检查人" align="center" prop="inspectedUsers">
            </el-table-column>
            <el-table-column label="发现时间" align="center" prop="createTime"/>
  
            <el-table-column label="隐患部位" align="center" prop="position" />
            <el-table-column label="隐患等级" align="center" prop="level">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.level == 1" type="warning"
                  >一般隐患</el-tag
                >
                <el-tag v-if="scope.row.level == 2" type="danger"
                  >重大隐患</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column
              label="整改期限"
              align="center"
              prop="limitedTime"
              width="180"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.limitedTime, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
            <el-table-column label="状态" align="center" prop="approStatus">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.approStatus == 1" type="warning"
                  >待审</el-tag
                >
                <el-tag v-if="scope.row.approStatus == 2" type="success"
                  >通过</el-tag
                >
                <el-tag v-if="scope.row.approStatus == 3" type="danger"
                  >驳回</el-tag
                >
                <el-tag v-if="scope.row.approStatus == 4" type="info"
                  >撤销</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              align="center"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-view"
                  @click="Details(scope.row.flowDetails)"
                  >查看详细</el-button
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="ListVehiclestotal > 0"
            :total="ListVehiclestotal"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-tab-pane>
        <el-tab-pane label="待审核" name="second">
          <el-table :data="listByMyslef">
            <el-table-column type="selection" width="55" align="center" />
            <!-- <el-table-column label="标题" align="center" prop="title" /> -->
            <el-table-column label="发现问题" align="center" prop="desci">
            </el-table-column>
            <el-table-column label="检查人" align="center" prop="inspectedUsers">
            </el-table-column>
            <el-table-column label="发现时间" align="center" prop="createTime"/>
  
            <el-table-column label="隐患部位" align="center" prop="position" />
            <el-table-column label="隐患等级" align="center" prop="level">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.level == 1" type="warning"
                  >一般隐患</el-tag
                >
                <el-tag v-if="scope.row.level == 2" type="danger"
                  >重大隐患</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column
              label="整改期限"
              align="center"
              prop="limitedTime"
              width="180"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.limitedTime, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
  
            <el-table-column
              label="操作"
              align="center"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-view"
                  @click="myDetails(scope.row)"
                  >去审核</el-button
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="listByMysleftotal > 0"
            :total="listByMysleftotal"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-tab-pane>
        <el-tab-pane label="已审核" name="third">
          <el-table :data="FlowList">
            <el-table-column type="selection" width="55" align="center" />
            <!-- <el-table-column label="标题" align="center" prop="title" /> -->
            <el-table-column label="发现问题" align="center" prop="desci">
            </el-table-column>
            <el-table-column label="检查人" align="center" prop="inspectedUsers">
            </el-table-column>
            <el-table-column label="发现时间" align="center" prop="createTime"/>
  
            <el-table-column label="隐患部位" align="center" prop="position" />
            <el-table-column label="隐患等级" align="center" prop="level">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.level == 1" type="warning"
                  >一般隐患</el-tag
                >
                <el-tag v-if="scope.row.level == 2" type="danger"
                  >重大隐患</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column
              label="整改期限"
              align="center"
              prop="limitedTime"
              width="180"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.limitedTime, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
            <el-table-column label="状态" align="center" prop="flag">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.flag == 1" type="success"
                  >已完成</el-tag
                >
                <el-tag v-if="scope.row.flag == 0" type="warning"
                  >未完成</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column label="责任人" align="center" prop="responUser" />
            <el-table-column label="责任部门" align="center" prop="deptName" />
            <el-table-column
              label="操作"
              align="center"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-view"
                  @click="goCorrect(scope.row)"
                  >去整改</el-button
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="FlowListtotal > 0"
            :total="FlowListtotal"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-tab-pane>
        <el-tab-pane label="整改" name="fourth">
          <el-table :data="Rectification" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" />
            <!-- <el-table-column label="标题" align="center" prop="title" /> -->
            <el-table-column label="发现问题" align="center" prop="desci">
            </el-table-column>
            <el-table-column label="检查人" align="center" prop="inspectedUsers">
            </el-table-column>
            <el-table-column label="发现时间" align="center" width="155" prop="createTime"/>
  
            <el-table-column label="隐患部位" align="center" prop="position" />
            <el-table-column label="隐患等级" align="center" prop="level">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.level == 1" type="warning"
                  >一般隐患</el-tag
                >
                <el-tag v-if="scope.row.level == 2" type="danger"
                  >重大隐患</el-tag
                >
              </template>
            </el-table-column>
            <el-table-column label="隐患图片" align="center" prop="photo">
              <template slot-scope="scope">
                <el-image
                  style="width: 100px; height: 100px"
                  :src="scope.row.photo.split(',')[0]"
                  :preview-src-list="scope.row.photo.split(',')"
                ></el-image>
              </template>
            </el-table-column>
            <el-table-column label="整改图片" align="center" prop="photo">
              <template slot-scope="scope">
                <el-image
                  style="width: 100px; height: 100px"
                  :src="scope.row.rectPhoto.split(',')[0]"
                  :preview-src-list="scope.row.rectPhoto.split(',')"
                ></el-image>
              </template>
            </el-table-column>
            <el-table-column
              label="整改期限"
              align="center"
              prop="limitedTime"
              width="180"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.limitedTime, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
            <el-table-column label="责任人" align="center" prop="responUser" />
            <el-table-column label="责任部门" align="center" prop="deptName" />
            <el-table-column
              label="操作"
              align="center"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-view"
                  @click="Details(scope.row.flowDetails)"
                  >详情</el-button
                >
              </template>
            </el-table-column>
          </el-table>
  
          <pagination
            v-show="Rectificationtotal > 0"
            :total="Rectificationtotal"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-tab-pane>
      </el-tabs>
  
      <!-- 添加、隐患 -->
      <el-dialog
        :title="title"
        :visible.sync="open"
        width="700px"
        append-to-body
        @close="openClose"
      >
        <div class="top">
          <el-steps :space="200" :active="stepIndex" finish-status="success">
            <el-step title="数据录入"></el-step>
            <el-step title="选择审批人"></el-step>
            <el-step title="选择整改人"></el-step>
            <el-step title="发起审核"></el-step>
          </el-steps>
        </div>
        <div class="contentForm" v-if="stepIndex == 0">
          <el-form ref="form" :model="form" :rules="rules" label-width="100px">
            <!-- <el-form-item label="标题" prop="title">
              <el-input v-model="form.title" placeholder="请输入标题" />
            </el-form-item> -->
            <el-row>
              <el-col :span="24">
                <el-form-item label="发现问题" prop="desci">
                  <el-input
                    v-model="form.desci"
                    placeholder="请输入发现的问题"
                  /> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="检查人" prop="desci">
                  <!-- <el-cascader
                    placeholder="部门"
                    :options="deptOptions"
                    :props="{ value: 'id' }"
                    @change="cascaderChange"
                    filterable
                  ></el-cascader> -->
                  <el-select
                    v-model="form.inspectedUsers"
                    multiple
                    collapse-tags
                    filterable
                    placeholder="选择人员*输入以搜索"
                  >
                    <el-option
                      v-for="item in userSelectList"
                      :key="item.userId"
                      :label="item.nickName"
                      :value="item.nickName"
                    ></el-option>
                  </el-select> </el-form-item
              ></el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="隐患部位" prop="position">
                  <el-input
                    v-model="form.position"
                    placeholder="请输入隐患部位"
                  /> </el-form-item
              ></el-col>
              <el-col :span="12">
                <el-form-item label="隐患等级" prop="level">
                  <el-select v-model="form.level" placeholder="请选择隐患等级">
                    <el-option label="一般隐患" :value="1"></el-option>
                    <el-option label="重大隐患" :value="2"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
  
            <el-row>
              <!-- submit -->
              <el-col :span="12">
                <el-form-item label="整改期限" prop="limtedlime">
                  <el-date-picker
                    clearable
                    v-model="form.limitedTime"
                    type="datetime"
                    placeholder="请选择整改期限"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    default-time="00:00:00"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input
                    v-model="form.remark"
                    placeholder="请输入备注"
                    type="textarea"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-divider>隐患图片</el-divider>
            <el-form-item label="" prop="photo" label-width="0px">
              <!-- <el-upload action="#" list-type="picture-card" :auto-upload="false" :http-request="fileRequest">
                  <i slot="default" class="el-icon-plus"></i>
                  <div slot="file" slot-scope="{ file }">
                    <img
                      class="el-upload-list__item-thumbnail"
                      :src="file.url"
                      alt=""
                    />
                    <span class="el-upload-list__item-actions">
                      <span
                        class="el-upload-list__item-preview"
                        @click="handlePictureCardPreview(file)"
                      >
                        <i class="el-icon-zoom-in"></i>
                      </span>
                      <span
                        v-if="!disabled"
                        class="el-upload-list__item-delete"
                        @click="handleDownload(file)"
                      >
                        <i class="el-icon-download"></i>
                      </span>
                      <span
                        v-if="!disabled"
                        class="el-upload-list__item-delete"
                        @click="handleRemove(file)"
                      >
                        <i class="el-icon-delete"></i>
                      </span>
                    </span>
                  </div>
                </el-upload> -->
              <el-upload
                class="upload-demo"
                action="#"
                ref="upload"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                multiple
                :limit="3"
                :on-exceed="handleExceed"
                :file-list="fileList"
                :http-request="handleFileUpload"
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  将文件拖到此处，或 <em>点击选取</em>
                </div>
              </el-upload>
            </el-form-item>
            <!-- <el-row>
                <el-col :span="12">
                  <el-form-item label="责任部门" prop="deptName">
                      <el-input v-model="form.deptName" placeholder="请输入责任部门"/>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="责任人" prop="responUserId">
                      <el-input v-model="form.responUserId" placeholder="请输入责任人"/>
                  </el-form-item>
                </el-col>
              </el-row> -->
          </el-form>
        </div>
        <div class="contentForm" v-if="stepIndex == 1">
          <div class="topSearch">
            <el-input
              v-model="userPage.userName"
              placeholder="请输入姓名查询"
              clearable
              size="small"
              prefix-icon="el-icon-search"
              style="margin-bottom: 10px; height: 40px"
            />
            <el-button
              @click="userSearch"
              type="primary"
              style="margin-bottom: 17px; height: 33px"
              >搜索</el-button
            >
          </div>
          <div class="userContent">
            <el-tree
              :data="deptOptions"
              :props="defaultProps"
              :expand-on-click-node="false"
              :filter-node-method="filterNode"
              ref="tree"
              node-key="id"
              default-expand-all
              highlight-current
              @node-click="handleNodeClick"
            />
  
            <div class="userList">
              <span
                v-for="item in userList"
                :key="item.userId"
                @click="addUser(item)"
                >{{ item.nickName }}</span
              >
            </div>
  
            <div class="userFooter">
              <span @click="userFooterbefor()">上一页</span>
              <span @click="userFooternext()">下一页</span>
            </div>
          </div>
          <el-divider>审批人</el-divider>
          <div class="spUser">
            <span v-for="item in checkUserList" :key="item.userId"
              >{{ item.nickName
              }}<i class="close el-icon-close" @click="userClose(item.userId)"></i
            ></span>
          </div>
  
          <svg
            t="1702351083987"
            class="icon"
            viewBox="0 0 34578 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="5820"
            width="200"
            height="5"
          >
            <path
              d="M0.98794 853.827303h32873.7096v169.184757H0.98794z m32873.7096-853.580318l1704.196816 1022.765075h-1704.196816z m0 0"
              fill="#13227a"
              p-id="5821"
            ></path>
          </svg>
          <span>将按照此顺序进行审批</span>
        </div>
        <div class="contentForm" v-if="stepIndex == 2">
        <el-form :model="myForm" style="margin-top: 40px;">
          <el-row>
          <el-col :span="12">
            <el-form-item label="责任部门" prop="desci">
              <el-cascader
                placeholder="部门"
                :options="deptOptions"
                :props="{ value: 'label', multiple: true, emitPath: false }"
                :show-all-levels="false"
                @change="cascaderChange2"
                filterable
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="责任人" prop="desci">
              <el-select
                v-model="myForm.responUserId"
                collapse-tags
                filterable
                placeholder="选择人员"
              >
                <el-option
                  v-for="item in userSelectList"
                  :key="item.userId"
                  :label="item.nickName"
                  :value="item.userId"
                ></el-option>
                <!-- userListSearch -->
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        </el-form>
        <!-- <span>将按照此顺序进行审批</span> -->
      </div>
        <div class="contentForm" v-if="stepIndex == 3">
          <el-divider>隐患信息</el-divider>
          <el-descriptions>
            <!-- <el-descriptions-item label="人员">
              <span v-for="(item, index) in form.names" :key="index">{{
                item + "."
              }}</span>
            </el-descriptions-item> -->
            <el-descriptions-item label="发现问题">{{
              form.desci
            }}</el-descriptions-item>
            <el-descriptions-item label="检查人"><span v-for="(item, index) in form.inspectedUsers" :key="index">{{
                item + "."
              }}</span></el-descriptions-item>
            <el-descriptions-item label="隐患部位">{{
              form.position
            }}</el-descriptions-item>
            <el-descriptions-item label="隐患等级">{{
              form.level == 1 ? "一般隐患" : "重大隐患"
            }}</el-descriptions-item>
          </el-descriptions>
          <el-divider>审批人</el-divider>
          <span v-for="item in checkUserList" :key="item.userId"
            >{{ item.nickName
            }}<i class="close el-icon-close" @click="userClose(item.userId)"></i
          ></span>
        </div>
  
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" v-if="stepIndex != 0" @click="beforTip"
            >上一步</el-button
          >
          <el-button type="primary" v-if="stepIndex != 3" @click="nextTip"
            >下一步</el-button
          >
          <el-button type="primary" v-else @click="submit">提交审核</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 详情弹出框 -->
      <el-dialog
        title="详情"
        :visible.sync="detailOpen"
        width="1100px"
        append-to-body
      >
        <el-table :data="ditailList">
          <el-table-column label="审核人" align="center" prop="name" />
          <el-table-column label="审核顺序" align="center" prop="sort" />
          <el-table-column label="审核状态" align="center" prop="status">
            <template slot-scope="scope">
              {{ myStatus[scope.row.status] }}
            </template>
          </el-table-column>
          <el-table-column label="审核意见" align="center" prop="content">
            <template slot-scope="scope">
              {{ detailStatus[scope.row.status] }}
            </template>
          </el-table-column>
          <el-table-column label="审核时间" align="center" prop="auditTime" />
          <el-table-column label="备注" align="center" prop="remark" />
          <el-table-column label="签名" align="center" prop="sign">
            <template slot-scope="scope">
              <!-- {{scope.row.sign}} -->
              <img
                v-if="scope.row.sign"
                style="display: block; width: 80px; height: 40px"
                :src="scope.row.sign"
              />
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>
      <!-- 待我审核弹出框 -->
      <el-dialog :visible.sync="mydetailOpen" width="700px" append-to-body>
        <el-divider>隐患信息</el-divider>
        <el-descriptions>
          <el-descriptions-item label="发现问题">{{
            mydetailData.desci
          }}</el-descriptions-item>
          <el-descriptions-item label="检查人">{{
            mydetailData.inspectedUsers
          }}</el-descriptions-item>
          <el-descriptions-item label="隐患部位">{{
            mydetailData.position
          }}</el-descriptions-item>
          <el-descriptions-item label="隐患等级">{{
            mydetailData.level == 1 ? "一般隐患" : "重大隐患"
          }}</el-descriptions-item>
          <el-descriptions-item label="隐患图片">
            <!-- <el-image
                  style="width: 100px; height: 100px"
                  :src="mydetailData.photo.split(',')[0]"
                  fit="fill"></el-image> -->
          </el-descriptions-item>
        </el-descriptions>
        <el-divider>审批信息</el-divider>
        <!-- <el-image v-for="(item,index) in mydetailData.photo.split(',')" :key="index" style="width: 100px; height: 100px" :src="item" fit="fill"></el-image> -->
  
        <!-- 审批信息 -->
        <el-form ref="form" :model="myForm" :rules="myRules" label-width="80px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="审核" prop="thing">
                <el-switch
                  v-model="myForm.status"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  :active-value="3"
                  :inactive-value="4"
                  active-text="同意"
                  inactive-text="不同意"
                >
                </el-switch>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="签名" prop="thing">
                <div
                  @click="signLog = true"
                  style="width: 200px; background-color: #d9d9d9"
                >
                  <el-image
                    :src="signinimg"
                    style="
                      width: 200px;
                      height: 100px;
                      display: flex;
                      align-items: center;
                      justify-content: center;
                      color: #999;
                    "
                  >
                    <div slot="error">点击签名</div>
                  </el-image>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="审核意见" prop="thing"
                ><el-input v-model="myForm.content" placeholder="请输入意见"
              /></el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="24">
              <el-form-item>
                <el-button type="primary" @click="mySunbit()">提交</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-dialog>
      <!-- 弹出框 -->
      <el-dialog :visible.sync="outOpen" width="700px" append-to-body>
        <el-divider>离场审批</el-divider>
        <el-form ref="form" :model="outForm" :rules="outRules" label-width="80px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="离场审批" prop="thing">
                <el-select v-model="outForm.flag" placeholder="请选择">
                  <el-option label="可以出场" :value="1" />
                  <el-option label="禁止出厂" :value="0" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="离场时间" prop="thing">
                <el-date-picker
                  v-model="outForm.departureTime"
                  type="datetime"
                  placeholder="选择日期时间"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  default-time="12:00:00"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item>
                <el-button type="primary" @click="permitOut()">提交</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-dialog>
      <!-- 上传图片弹出框 -->
      <el-dialog :visible.sync="dialogVisible">
        <img width="100%" :src="dialogImageUrl" alt="" />
      </el-dialog>
      <!-- 整改弹出框 -->
      <el-dialog :visible.sync="correctShow">
        <el-form
          ref="form"
          :model="correctForm"
          :rules="myRules"
          label-width="80px"
        >
          <el-divider>整改后图片</el-divider>
          <el-row>
            <el-col :span="24">
              <el-upload
                class="upload-demo"
                action="#"
                ref="upload"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                multiple
                :limit="3"
                :on-exceed="handleExceed"
                :file-list="fileList"
                :http-request="handleFileUpload2"
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  将文件拖到此处，或 <em>点击选取</em>
                </div>
              </el-upload>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="整改措施" prop="position">
                <el-input
                  v-model="correctForm.measure"
                  placeholder="请输入整改措施"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="审核" prop="thing">
            <el-switch
              v-model="correctForm.flag"
              active-color="#13ce66"
              inactive-color="#ff4949"
              :active-value="1"
              :inactive-value="0"
              active-text="同意"
              inactive-text="不同意"
            >
            </el-switch>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="correctSunbit()">提交</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <!-- 电子签名 -->
      <el-dialog title="电子签名" :visible.sync="signLog" width="700px">
        <signinDia @setsignin="setsignin"></signinDia>
      </el-dialog>
    </div>
  </template>
        
        <script>
  import {
    checkeddangerhidden, //已审核
    adddangerhidden, //新增隐患
    balstLibraryPass, //已经通过
    dangerhiddenDiscover, // 隐患发现
    dangerhiddenLoding,
    dangerhiddenUpdate,
    dangerhiddenOk,
    dangerhidden,
    listRectification,
    dangerDownload,
    delBalstLibrary
  } from "@/api/app/greatInspect";

  import { deptTreeSelect, listUser } from "@/api/system/user";
  //import { listUser } from "@/api/system/user";
  import cache from "@/plugins/cache";
  import { uploadPhoto } from "@/api/city.js";
  
  import signinDia from "@/components/signFont/index.vue";
  
  export default {
    components: {
      signinDia,
    },
    name: "Vehicles",
    data() {
      return {
        flowNos:null,
        correctShow: false,
        correctForm: {
          flag: 1,
          measure: null,
          flowNo: null,
          rectPhoto: [],
        },
        userListSearchName: "",
        signinimg: null,
        signLog: false,
        dialogImageUrl: "",
        dialogVisible: false,
        disabled: false,
        stepIndex: 0,
        userId: cache.session.getJSON("userId"),
        ListVehicles: [],
        listByMyslef: [],
        FlowList: [],
        Rectification: [],
        fileList: [],
        activeName: "first",
        deptOptions: [],
        userSelectList: [],
        card: "",
        myStatus: {
          1: "审核中",
          2: "待我审核",
          3: "通过",
          4: "驳回",
        },
        detailStatus: {
          // 1: "待审核",
          3: "通过",
          4: "驳回",
          // 4: "撤销",
        },
  
        defaultProps: {
          children: "children",
          label: "label",
        },
        // 部门名称
        deptName: undefined,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        ListVehiclestotal: 0,
        listByMysleftotal: 0,
        FlowListtotal: 0,
        Rectificationtotal:0,
        // 外来车辆管理表格数据
        // vehiclesList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        detailOpen: false,
        mydetailOpen: false,
        lodingData: {},
        outOpen: false,
        mydetailData: {},
        ditailList: [],
        // 是否离场时间范围
        daterangeTime: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          beginCreateTime:null,
          inspectedUsers:null,
          level:null,
        },
        // 表单参数
        form: {
          photo: [],
        },
        myForm: {
          flowNo: null,
          status: 3,
          auditUserId: null,
          sign: null,
          id: null,
          content: "",
          deptName: [],
          responUserId: null,
        },
        outForm: {
          flowNo: null,
          flag: 1,
          departureTime: null,
        },
        // 表单校验
        rules: {},
        myRules: {},
        outRules: {},
        //人员数据
        userList: [],
        checkUserList: [],
        userPage: {
          pageNum: 1,
          pageSize: 24,
          deptId: null,
          userName: "",
        },
      };
    },
    created() {
      this.getList();
  
      this.getDeptTree();
  
      this.getUserList();
    },
    watch: {
      // 根据名称筛选部门树
      deptName(val) {
        this.$refs.tree.filter(val);
      },
    },
    methods: {
      

downloadPDF() {
      if (this.flowNos != null && this.flowNos != '') {
        dangerDownload(this.flowNos).then((res) => {
        console.log(res);
        if (res.success) {
          window.open(res.data)
        }
      });
      }else {
        this.$message.error('未选择导出项')
      }
      
    },
    handleSelectionChange(val){
      console.log(val);
      let flowNos =  val.map(item=>{
        return item.flowNo
      })
      this.flowNos = flowNos.join()
    },
      setsignin(img) {
        this.signinimg = img;
        this.signLog = false;
        this.myForm.sign = img;
      },
      // 处理移除操作
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      // 处理预览操作
      handlePreview(file) {
        console.log(file);
      },
      // 处理超出图片个数操作
      handleExceed(files, fileList) {
        this.$message.warning(
          `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
            files.length + fileList.length
          } 个文件`
        );
      },
      // 移除之前的操作
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${file.name}？`);
      },
      // 处理文件上传操作
      handleFileUpload(file) {
        let that = this;
        console.log(that.form);
        this.loading = true;
        // 调用后端服务器的接口
        let data = new FormData();
        data.append("file", file.file);
        uploadPhoto("great", data)
          .then((resp) => {
            console.log(resp, that.form.photo);
            // that.form.photo.push(resp.data);
            that.form.photo.push(resp.data);
  
            console.log(that.form.photo);
          })
          .catch((e) => {
            this.$message.error(e.message);
            this.$refs.upload.clearFiles();
          });
      },
      // 整改处理文件上传操作
      handleFileUpload2(file) {
        let that = this;
        this.loading = true;
        // 调用后端服务器的接口
        let data = new FormData();
        data.append("file", file.file);
        uploadPhoto("great", data)
          .then((resp) => {
            console.log(resp, that.form.photo);
            // that.form.photo.push(resp.data);
            that.correctForm.rectPhoto.push(resp.data);
          })
          .catch((e) => {
            this.$message.error(e.message);
            this.$refs.upload.clearFiles();
          });
      },
      /** 查询外来车辆管理列表 */
      getList() {
        this.getListVehicles();
        this.getListByMyslef();
        this.getFlowList();
        this.getRectification();
      },
      // 查看来访详细
      Details(data) {
        console.log(data);
        this.detailOpen = true;
        this.ditailList = data;
      },
      //去审核
      myDetails(data) {
        console.log(data);
        this.myForm.flowNo = data.flowNo;
        this.myForm.id = data.id;
        this.mydetailOpen = true;
        this.mydetailData = data;
      },
      //去整改
      goCorrect(data) {
        console.log(data);
        this.correctShow = true;
        this.correctForm.flowNo = data.flowNo;
      },
      // 批准出矿
      out(flowNo) {
        this.outOpen = true;
        this.outForm.flowNo = flowNo;
      },
      // 添加框关闭
      openClose() {
        this.checkUserList = [];
        this.stepIndex = 0;
        this.reset();
      },
  
      /** 查询部门下拉树结构 */
      getDeptTree() {
        deptTreeSelect().then((response) => {
          this.deptOptions = response.data;
        });
      },
      // 查询人员
      userSearch() {
        listUser(this.userPage).then((res) => {
          this.userPage.deptId = null;
          // this.userPage.pageNum = 1;
          if (res.code == 200) {
            this.userList = res.rows;
            this.total = res.total;
          }
        });
      },
      // 人员上一页
      userFooterbefor() {
        if (this.userPage.pageNum >= 2) {
          console.log(this.userPage.pageNum);
          this.userPage.pageNum--;
          console.log(this.userPage.pageNum);
          this.userSearch();
        } else {
          this.$message("已经是第一页了");
        }
      },
      // 人员下一页
  
      userFooternext() {
        if (this.userPage.pageNum < Math.ceil(this.total / 12)) {
          this.userPage.pageNum++;
          console.log(this.userPage.pageNum);
          this.userSearch();
        } else {
          this.$message("已经是最后一页了");
        }
      },
  
      cascaderChange(data) {
        console.log(data);
        listUser({
          deptId: data[data.length - 1],
          peopleType: 1,
        }).then((res) => {
          this.userSelectList = res.rows;
        });
      },
      cascaderChange2(data) {
        console.log(data);
        this.myForm.deptName = data.join();
      },
  
      getUserList() {
        listUser({
          pageNum: 1,
          pageSize: 999,
        }).then((res) => {
          this.userSelectList = res.rows;
        });
      },
  
      userListSearch(username) {
        this.responUserId = username;
        console.log(username);
        listUser({ pageNum: 1, pageSize: 999, userName: username }).then(
          (res) => {
            if (res.code == 200) {
              console.log(res);
              this.userList = res.rows;
              this.total = res.total;
            }
          }
        );
      },
  
      //添加审批人
      addUser(item) {
        if (
          JSON.stringify(this.checkUserList).indexOf(JSON.stringify(item)) === -1
        ) {
          this.checkUserList.push(item);
        } else {
          this.$message.error("该审批人已经存在");
        }
      },
      // 删除审批用户
      userClose(id) {
        this.checkUserList.some((item, i) => {
          if (item.userId === id) {
            this.checkUserList.splice(i, 1);
          }
        });
      },
      // 提交审批
      submit() {
        // this.reset();
        let data = { ...this.form };
        data.userId = this.userId;
        data.flag = 0;
        data.type = 5;
        data.category = 6;
        data.photo = data.photo.join();
        data.inspectedUsers = data.inspectedUsers.join();
  
        data.flowDetails = [];
        this.checkUserList.forEach((item, index) => {
          data.flowDetails.push({ auditUserId: item.userId, sort: index + 1 });
        });
  
        console.log(data);
        // return;
        adddangerhidden(data).then((res) => {
          if (res.code == 200) {
            this.$modal.msgSuccess("提交成功");
            this.open = false;
            this.reset();
            this.stepIndex = 0;
            this.checkUserList = [];
            this.getList();
          } else {
            this.open = false;
            this.reset();
            this.stepIndex = 0;
            this.checkUserList = [];
            this.getList();
            this.$message.error("提交失败");
          }
        });
      },
      // 我的审核
      mySunbit() {
        this.myForm.auditUserId = this.userId;
        dangerhiddenUpdate(this.myForm).then((res) => {
          if (res.code == 200) {
            this.$message("审批完成");
          } else {
            this.$message.error("失败");
          }
          this.mydetailOpen = false;
          this.getList();
        });
      },
      correctSunbit() {
        console.log(this.correctForm);
        this.correctForm.rectPhoto = this.correctForm.rectPhoto.join();
        dangerhidden(this.correctForm).then((res) => {
            this.$modal.msgSuccess('提交成功')
          this.correctShow = false
          this.getList();
        });
      },
      // 筛选节点
      filterNode(value, data) {
        if (!value) return true;
        return data.label.indexOf(value) !== -1;
      },
      // 节点单击事件
      handleNodeClick(data) {
        this.userPage.deptId = data.id;
  
        this.userPage.pageNum = 1;
  
        this.userSearch();
      },
  
      // 隐患发现
      async getListVehicles() {
        await dangerhiddenDiscover({
          ...this.queryParams,
          userId: this.userId,
          type: 5,
          category: 6,
        }).then((res) => {
          console.log(res, "隐患发现");
          if (res.code == 200) {
            this.ListVehicles = res.rows;
            this.ListVehiclestotal = res.total;
          }
        });
      },
      // 待审核
      async getListByMyslef() {
        await dangerhiddenLoding({
          ...this.queryParams,
          userId: this.userId,
          type: 5,
          category: 6,
        }).then((res) => {
          console.log(res, "待审核");
          if (res.code == 200) {
            this.listByMyslef = res.rows;
            this.listByMysleftotal = res.total;
          }
        });
      },
      toSplit(url) {
        console.log(url, url.split(","));
        return url.split(",");
      },
      //已审核
      async getFlowList() {
        await dangerhiddenOk({
          ...this.queryParams,
          approStatus: 2,
          userId: this.userId,
          type: 5,
          category: 6,
        }).then((res) => {
          console.log(res, "已审核");
          if (res.code == 200) {
            this.FlowList = res.rows;
            this.FlowListtotal = res.total;
          }
        });
      },
      //已整改
      async getRectification() {
        await listRectification({
          ...this.queryParams,
  
          approStatus: 2,
          userId: this.userId,
          type: 5,
          category: 6,
          flag: 1,
        }).then((res) => {
          console.log(res, "已整改");
          if (res.code == 200) {
            this.Rectification = res.rows;
            this.Rectificationtotal = res.total;
          }
        });
      },
      //上一步
      beforTip() {
        this.stepIndex--;
      },
      //下一步
      nextTip() {
        if (this.stepIndex == 0) {
        } else if (this.stepIndex == 3) {
          return;
        }
        this.stepIndex++;
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          userId: null,
          title: null,
          desci: null, //发现问题
          photo: [],
          position: null, //隐患部位
          limitedTime: null, //整改期限
          level: null, //隐患等级 隐患等级(1是一般隐患，2是重大隐患)
          remark: null, //备注
          inspectedUsers: [], //检查人（数组存储）
          flowDetails: [],
          flag: 0,
          type: 5,
          category: 6,
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
          this.queryParams= {
          pageNum: 1,
          pageSize: 10,
          beginCreateTime:null,
  
          inspectedUsers:null,
          level:null,
        },
        this.daterangeTime = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
  
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.getDeptTree();
        this.open = true;
        this.title = "新增隐患";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids;
        getVehicles(id).then((response) => {
          this.form = response.data;
          this.open = true;
          this.title = "修改外来车辆管理";
        });
      },
    //   handleDelete() {
    //   if (this.flowNos != null && this.flowNos != "") {
    //     delBalstLibrary(this.flowNos).then((res) => {
    //       console.log(res);
    //       if (res.code == 200) {
    //         this.$modal.msgSuccess("删除成功");
    //         this.getList();
    //       }
    //     });
    //   } else {
    //     this.$message.error("未选择删除项");
    //   }
    // },
    handleDelete() {
      if (this.flowNos != null && this.flowNos != "") {
        delBalstLibrary(this.flowNos).then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.$modal.msgSuccess("删除成功");
            this.getList();
          }
        });
      } else {
        this.$message.error("未选择删除项");
      }
    },
    },
  };
  </script>
        <style lang='scss' scoped>
  .el-tree {
    width: 30%;
  }
  .topSearch {
    display: flex;
    align-items: center;
  }
  .userContent {
    display: flex;
  }
  .userList {
    display: inline-grid;
    grid-template-columns: 100px 100px 100px 100px;
    // grid-template-rows: 50px 50px;
    grid-gap: 5px;
    width: 70%;
    height: 100%;
    span {
      // width: 25%;
      padding: 8px;
      text-align: center;
      background-color: #ccc;
    }
  }
  
  .userFooter {
    position: absolute;
    right: 0;
    top: 500px;
    span {
      margin: 20px;
      color: #1890ff;
      cursor: pointer;
    }
  }
  .spUser {
    display: flex;
    span {
      position: relative;
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background-color: #27aa07;
      color: aliceblue;
      margin: 6px;
      text-align: center;
      line-height: 50px;
  
      .close {
        position: absolute;
        color: #000;
        top: 0;
        right: -5px;
        font-weight: 700;
        cursor: pointer;
        display: none;
      }
    }
    span:hover .close {
      display: block;
    }
  }
  </style>